private Command nextCommand = new Command("Next", 4, 1);
private Command helpCommand = new Command("Help", 4, 1);
private Command backCommand = new Command("Back", 4, 1);
private Command exitCommand = new Command("Exit", 4, 2);
private Command computeCommand = new Command("Compute", 4, 1);
private StringItem helpStringItem;
private StringItem openingStringItem;
private StringItem resultStringItem;
private DateField fromDF;
private DateField toDF;
private Image img;
private ImageItem imgItem;
public DateToDate() {
try {
this.img = Image.createImage("/looach.png");
this.imgItem = new ImageItem("", this.img, 0, "[TIME_TABLE]");
this.openingForm.append(this.imgItem);
} catch (IOException var2) {
((Throwable)var2).printStackTrace();
}
this.openingStringItem = new StringItem("DateToDate v1.1Beta\nwas developed by", "\nJACADO\nwww.jacado.com\nThis software is provided \"AS IS\", without warranty of any kind. In no event, shell we be liable for any claim, damages or other liability. Copyright(c)2001 Haim Michael, JACADO & ZINDELL Ltd. All rights reserved.");
this.openingForm.append(this.openingStringItem);
this.openingForm.addCommand(this.nextCommand);
this.openingForm.addCommand(this.helpCommand);
this.openingForm.setCommandListener(this);
this.display.setCurrent(this.openingForm);
this.helpForm = new Form("Help");
this.helpStringItem = new StringItem("Instructions", " This midlet computes the difference (in days) between two dates. You should choose two dates an press \"Compute\".");
this.helpForm.append(this.helpStringItem);
this.helpForm.addCommand(this.backCommand);
this.helpForm.setCommandListener(this);
this.mainForm = new Form("DateToDate");
this.fromDF = new DateField("From", 1);
this.toDF = new DateField("To", 1);
Date temp = Calendar.getInstance().getTime();
this.fromDF.setDate(temp);
this.toDF.setDate(temp);
this.mainForm.append(this.fromDF);
this.mainForm.append(this.toDF);
this.mainForm.addCommand(this.exitCommand);
this.mainForm.addCommand(this.computeCommand);
this.mainForm.setCommandListener(this);
this.resultForm = new Form("Result");
this.resultStringItem = new StringItem("The difference between the two dates is", " 0 days");
this.resultForm.append(this.resultStringItem);
this.resultForm.addCommand(this.exitCommand);
this.resultForm.addCommand(this.backCommand);
this.resultForm.setCommandListener(this);
}
public void commandAction(Command c, Displayable d) {
if (d == this.openingForm) {
if (c == this.helpCommand) {
this.display.setCurrent(this.helpForm);
} else if (c == this.nextCommand) {
this.display.setCurrent(this.mainForm);
}
} else if (d == this.helpForm) {
if (c == this.backCommand) {
this.display.setCurrent(this.openingForm);
}
} else if (d == this.mainForm) {
if (c == this.exitCommand) {
this.exit();
} else if (c == this.computeCommand) {
long fromTemp = this.fromDF.getDate().getTime();
long toTemp = this.toDF.getDate().getTime();
long days = (toTemp - fromTemp) / 86400000L;
this.resultStringItem.setText(" " + days + " days");